package com.github.dengmin.mysql.dao.impl;

import com.github.dengmin.mysql.common.SQL;
import com.github.dengmin.mysql.dao.UserDao;
import com.github.dengmin.mysql.mapper.UserRowMapper;
import com.github.dengmin.mysql.model.User;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @Author dengmin
 * @Created 2020/7/1 下午3:55
 */
@Repository
public class UserDaoImpl implements UserDao {
    private static final long serialVersionUID = 1L;

    @Resource
    private JdbcTemplate jdbcTemplate;
    @Override
    public User getByName(String name) {
        try {
            return jdbcTemplate.queryForObject(SQL.queryUserByName, new UserRowMapper(), name);
        }catch (Exception e){
            return null;
        }
    }
}
